<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="Head.jsp" %>
<title>Register</title>
</head>

<body>

<%-- Header --%>
<%@ include file="Header.jsp" %>

<h1>U A NUBZ?</h1>

<%-- Display errors --%>
<c:if test="${not empty errors}">
  <p class="error">
  ${errors}
  </p>
</c:if>

<c:if test="${not empty profil}">
  <a href="MyContents?username=${username}">See Posts</a>
</c:if>

<form action="Register" method="post" enctype="multipart/form-data">
<ul>
	<c:if test="${not empty register}">
    <li>Username: <input type="text" name="username" value="${username}"/></li>
	  <li>Password: <input type="password" name="password"/></li>
	  <li>Password (Again): <input type="password" name="password_again"/></li>
	</c:if>

  <li>Full Name: <input type="text" name="full_name" value="${full_name}"/></li>
  <li>Birthday: <input type="text" name="birthday" value="${birthday}"/></li>
  <li>Email: <input type="text" name="email" value="${email}"/></li>
  <li>Avatar:
	  <c:if test="${not empty profil}">
	    <img src="/snsdbook/avatar/${avatar}" height="42" width="42" />
	  </c:if>
    <input type="file" name="avatar"/>
  </li>
  <li>
    <c:choose>
	    <c:when test="${not empty gender}">
	      <c:choose>
		      <c:when test="${gender=='L'}">
		        <input type="radio" name="gender" value="L" checked/> Male
		        <input type="radio" name="gender" value="P"/> Female
		      </c:when>
		      <c:otherwise>
		        <input type="radio" name="gender" value="L"/> Male
		        <input type="radio" name="gender" value="P" checked/> Female
		      </c:otherwise>
	      </c:choose>
	    </c:when>
	    <c:otherwise>
	      <input type="radio" name="gender" value="L"/> Male
        <input type="radio" name="gender" value="P"/> Female
	    </c:otherwise>
    </c:choose>
  </li>
  <li>About me: <br/>
      <textarea name="about" rows="10" cols="50">${about}</textarea>
  </li>
  
	<c:if test="${not empty profil}">
	  <li>Achievements:
  	  <ul>
	     <c:forEach var="ach" items="${achievements}">
         <li>${ach}</li>
       </c:forEach>
	   </ul>
	  </li>
	  
	  <li>Comments: ${comment_count}</li>
	  <li>Posts: ${post_count}</li>
	</c:if>
</ul>

<c:if test="${not empty profil}">
  <input type="hidden" name="type" value="change"/>
  <c:if test="${sessionScope.username == username}">
    <input type="submit" value="Change" id="post_button"/>
  </c:if>
</c:if>
<c:if test="${not empty register}">
  <input type="hidden" name="type" value="register"/>
  <input type="submit" value="Register" id="post_button"/>
</c:if>


</form>

</body>
</html>